package com.xxxx.server.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xxxx.server.pojo.Admin;
import com.xxxx.server.pojo.Ivaccine;
import com.xxxx.server.mapper.IvaccineMapper;
import com.xxxx.server.pojo.RespPageBean;
import com.xxxx.server.service.IIvaccineService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 辅导员疫苗登记表 服务实现类
 * </p>
 *
 * @author zhoubin
 * @since 2022-06-01
 */
@Service
public class IvaccineServiceImpl extends ServiceImpl<IvaccineMapper, Ivaccine> implements IIvaccineService {

    @Autowired
    private IvaccineMapper ivaccineMapper;
    @Override
    public List<Ivaccine> getByColegeIdIvaccines() {
        return ivaccineMapper.getByColegeIdIvaccines(((Admin) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getCollegeid());
    }

    @Override
    public RespPageBean getInvaccineByPage(Integer currentPage, Integer size, Ivaccine ivaccine, String[] beginDateScope, int type, String collegeName,int collegeid) {
        //开启分页
        Page<Ivaccine> page = new Page<>(currentPage,size);
        IPage<Ivaccine> ivaccineByPage = ivaccineMapper.getInvaccineByPage(page, ivaccine, beginDateScope,type,collegeName,collegeid);
        RespPageBean respPageBean = new RespPageBean(ivaccineByPage.getTotal(), ivaccineByPage.getRecords());
        return respPageBean;
    }

    @Override
    public List<Ivaccine> getInvaccineSeachList(Ivaccine ivaccine, String[] beginDateScope, int type, String collegename, int collegeid) {
        return ivaccineMapper.getInvaccineSeachList(ivaccine, beginDateScope,type,collegename,collegeid);
    }


}
